<template>
  <div id="index" ref="appRef">
    <div class="bg">
      <dv-loading v-if="loading">Loading...</dv-loading>
      <div v-else class="host-body">
        <div class="d-flex jc-center">
          <dv-decoration-10 class="dv-dec-10" />
          <div class="d-flex jc-center">
            <dv-decoration-8 class="dv-dec-8" :color="['#568aea', '#000000']" />
            <div class="title">
              <span class="title-text">大数据可视化平台</span>
              <dv-decoration-6
                class="dv-dec-6"
                :reverse="true"
                :color="['#50e3c2', '#67a1e5']"
              />
            </div>
            <dv-decoration-8
              class="dv-dec-8"
              :reverse="true"
              :color="['#568aea', '#000000']"
            />
          </div>
          <dv-decoration-10 class="dv-dec-10-s" />
        </div>

        <!-- 第二行 -->
        <div class="d-flex jc-between px-2">
          <div class="d-flex aside-width">
            <div class="react-left ml-4 react-l-s">
              <span class="react-before"></span>
              <span class="text">数据分析1</span>
            </div>
            <div class="react-right ml-3">
              <span class="text">数据分析2</span>
            </div>
          </div>
          <div class="d-flex aside-width">
            <div class="react-right bg-color-blue mr-3">
              <span class="text fw-b">vue-big-screen</span>
            </div>
            <div class="react-right mr-4 react-l-s">
              <span class="react-after"></span>
              <span class="text"
                >{{ dateYear }} {{ dateWeek }} {{ dateDay }}</span
              >
            </div>
          </div>
        </div>

        <div class="body-box">
          <!-- 第三行数据 -->
          <div class="content-box">
            <div>
              <dv-border-box-13>
                <div class="d-flex pt-2 pl-2 title">
                  <span>
                    <icon name="chart-bar" class="text-icon"></icon>
                  </span>
                  <div class="d-flex">
                    <span class="fs-xl text mx-2">洒水道路作业情况、作业达标情况</span>
                  </div>
                </div>
                <div
                  id="WorkOnStandard_SS"
                  style="width: 95%; height: 400px"
                ></div>
              </dv-border-box-13>
            </div>
            <div>
              <dv-border-box-13>
                <div class="d-flex pt-2 pl-2 title">
                  <span>
                    <icon name="chart-bar" class="text-icon"></icon>
                  </span>
                  <div class="d-flex">
                    <span class="fs-xl text mx-2">冲洗道路作业情况、作业达标情况</span>
                  </div>
                </div>
                <div
                  id="WorkOnStandard_CX"
                  style="width: 95%; height: 400px"
                ></div>
              </dv-border-box-13>
            </div>
            <div>
              <dv-border-box-13>
                <div class="d-flex pt-2 pl-2 title">
                  <span>
                    <icon name="chart-bar" class="text-icon"></icon>
                  </span>
                  <div class="d-flex">
                    <span class="fs-xl text mx-2">洗扫道路作业情况、作业达标情况</span>
                  </div>
                </div>
                <div
                  id="WorkOnStandard_XS"
                  style="width: 95%; height: 400px"
                ></div>
              </dv-border-box-13>
            </div>
            <div>
              <dv-border-box-13>
                <div class="d-flex pt-2 pl-2 title">
                  <span>
                    <icon name="chart-bar" class="text-icon"></icon>
                  </span>
                  <div class="d-flex">
                    <span class="fs-xl text mx-2">洗扫道路作业情况、作业达标情况</span>
                  </div>
                </div>
                <div
                  id="WorkOnStandard_JS"
                  style="width: 95%; height: 400px"
                ></div>
              </dv-border-box-13>
            </div>
          </div>
          <!-- 第四行数据 -->
          <div class="bototm-box">
            <dv-border-box-13>
              <!-- <bottomLeft /> -->
              <div class="d-flex pt-2 pl-2 title">
                  <span>
                    <icon name="chart-bar" class="text-icon"></icon>
                  </span>
                  <div class="d-flex">
                    <span class="fs-xl text mx-2">当日累计出车统计</span>
                  </div>
                </div>
                <div
                  id="WorkRatioByCartype"
                  style="width: 95%; height: 400px"
                ></div>
            </dv-border-box-13>
            <dv-border-box-13>
              <!-- <bottomRight /> -->
              <div style="width: 100%; height: 100%">
    <div style="width: 100%; height: 100%" id="map"></div>
  </div>
            </dv-border-box-13>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { newMap } from '@/common/map/map.js'
import { optionWorkOnStandard } from '@/components/echart/bar.js'
import { optionBarContainBarAndRatio } from '@/components/echart/bar.js'
import drawMixin from "../utils/drawMixin";
import { formatTime } from '../utils/index.js'
// import centerLeft1 from './centerLeft1'
// import centerLeft2 from './centerLeft2'
// import centerRight1 from './centerRight1'
// import centerRight2 from './centerRight2'
// import center from './center'
// import bottomLeft from './bottomLeft'
// import bottomRight from './bottomRight'
import * as echarts from 'echarts';
export default {
  mixins: [drawMixin],
  data () {
    return {
      form: {
        userName: 'dlhw',
        date: '2020-10',
        clientNo: '0000009',
      },
      timing: null,
      loading: false,
      dateDay: null,
      dateYear: null,
      dateWeek: null,
      weekday: ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
    }
  },
  components: {
    // centerLeft1,
    // centerLeft2,
    // centerRight1,
    // centerRight2,
    // center,
    // bottomLeft,
    // bottomRight
  },
  mounted () {
    this.initWorkOnStandard_SS()
    this.initWorkOnStandard_CX()
    this.initWorkOnStandard_XS()
    this.initWorkOnStandard_JS()
    this.initWorkRatioByCartype()
    this.timeFn()
    // this.cancelLoading()
    this.initMap()
  },
  beforeDestroy () {
    clearInterval(this.timing)
  },
  methods: {
    initMap () {
      // 百度地图API功能
      this.map = newMap();
    },
    async initWorkRatioByCartype () {
      // [{"GROUPNAME":null,"CAR_TYPE":"洗路车","ALLNUM":"93","CURRENTNUM":"57"},
      // {"GROUPNAME":null,"CAR_TYPE":"机扫车","ALLNUM":"27","CURRENTNUM":"17"},
      // {"GROUPNAME":null,"CAR_TYPE":"高压清洗车","ALLNUM":"41","CURRENTNUM":"12"},
      // {"GROUPNAME":null,"CAR_TYPE":"洒水车","ALLNUM":"55","CURRENTNUM":"16"},
      // {"GROUPNAME":null,"CAR_TYPE":"小型机扫车","ALLNUM":"25","CURRENTNUM":"5"},
      // {"GROUPNAME":null,"CAR_TYPE":"除雪车","ALLNUM":"6","CURRENTNUM":"2"},
      // {"GROUPNAME":null,"CAR_TYPE":"总计","ALLNUM":"247","CURRENTNUM":"104"}]
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById('WorkRatioByCartype'));
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(optionBarContainBarAndRatio(["作业车辆数","车辆总数","作业率"],{category: ["洗路车","机扫车","高压清洗车"],lineData: [93,27,41],barData: [57,17,12],
        rateData: [0.20,0.40,0.60,]}));
    },
    async initWorkOnStandard_SS () {
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById('WorkOnStandard_SS'));
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(optionWorkOnStandard());
      var url = "http://111.160.78.62:9935/api/EChartsYX/GetWorkOnStandard?sqlName=" + this.form.userName + "&url=exec T_GetVehicleRoadStandardInfo '" + this.form.date + "','" + this.form.clientNo + "',洒水";
      const { data } = await this.$Http.get(url)
      myChart.setOption({
        xAxis: {
          data: data.categories
        },
        series: [{
          data: data.dataWork
        }, {
          data: data.dataNotWork
        }, {
          data: data.dataOnStandard
        }, {
          data: data.dataNotStandard
        }]
      });
    },
    async initWorkOnStandard_CX () {
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById('WorkOnStandard_CX'));
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(optionWorkOnStandard());
      var url = "http://111.160.78.62:9935/api/EChartsYX/GetWorkOnStandard?sqlName=" + this.form.userName + "&url=exec T_GetVehicleRoadStandardInfo '" + this.form.date + "','" + this.form.clientNo + "',冲洗";
      const { data } = await this.$Http.get(url)
      myChart.setOption({
        xAxis: {
          data: data.categories
        },
        series: [{
          data: data.dataWork
        }, {
          data: data.dataNotWork
        }, {
          data: data.dataOnStandard
        }, {
          data: data.dataNotStandard
        }]
      });
    },
    async initWorkOnStandard_XS () {
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById('WorkOnStandard_XS'));
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(optionWorkOnStandard());
      var url = "http://111.160.78.62:9935/api/EChartsYX/GetWorkOnStandard?sqlName=" + this.form.userName + "&url=exec T_GetVehicleRoadStandardInfo '" + this.form.date + "','" + this.form.clientNo + "',洗扫";
      const { data } = await this.$Http.get(url)
      myChart.setOption({
        xAxis: {
          data: data.categories
        },
        series: [{
          data: data.dataWork
        }, {
          data: data.dataNotWork
        }, {
          data: data.dataOnStandard
        }, {
          data: data.dataNotStandard
        }]
      });
    },
    async initWorkOnStandard_JS () {
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById('WorkOnStandard_JS'));
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(optionWorkOnStandard());
      var url = "http://111.160.78.62:9935/api/EChartsYX/GetWorkOnStandard?sqlName=" + this.form.userName + "&url=exec T_GetVehicleRoadStandardInfo '" + this.form.date + "','" + this.form.clientNo + "',机扫";
      const { data } = await this.$Http.get(url)
      myChart.setOption({
        xAxis: {
          data: data.categories
        },
        series: [{
          data: data.dataWork
        }, {
          data: data.dataNotWork
        }, {
          data: data.dataOnStandard
        }, {
          data: data.dataNotStandard
        }]
      });
    },
    timeFn () {
      this.timing = setInterval(() => {
        this.dateDay = formatTime(new Date(), 'HH: mm: ss')
        this.dateYear = formatTime(new Date(), 'yyyy-MM-dd')
        this.dateWeek = this.weekday[new Date().getDay()]
      }, 1000)
    },
    cancelLoading () {
      setTimeout(() => {
        this.loading = false
        this.initC();
      }, 2000)
    }
  }
}
</script>

<style lang="scss">
@import '../assets/scss/index.scss';
//下方区域的布局
.content-box {
  display: grid;
  // grid-template-columns: 2.5fr 2.5fr 2.5fr 2.5fr;
  grid-template-columns: repeat(4, 25%);
}
// 底部数据
.bototm-box {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, 50%);
}
.title {
  padding-top: 25px;
  padding-left: 20px;
  .text {
    font-size: 15px;
  }
}
</style>
